package com.dldata.devtools30.repository.api;


import com.dldata.devtools30.entity.DevtApiSubEntity;
import com.dldata.devtools30.repository.BaseRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by ai on 2017/1/11.
 */
@Repository
public interface DevtApiSubEntityDao extends BaseRepository<DevtApiSubEntity,String>, JpaSpecificationExecutor<DevtApiSubEntity> {
        @Query("select d from DevtApiSubEntity d where d.mainid=?1 order by d.mc")
        public List<DevtApiSubEntity> getAllDataById(String mainid);


        @Query("select d from DevtApiSubEntity d where d.id=?1")
        public List<DevtApiSubEntity> getOneData(String id);


        @Query("select d from DevtApiSubEntity d where d.mainid=?1 and d.dm=?2")
        public List<DevtApiSubEntity> getOneDataByMainid(String mainid, String dm);


        @Query("select d from DevtApiSubEntity d where d.dm=?1 ")
        public List<DevtApiSubEntity> getOneDataByDm(String dm);


        @Query("select d from DevtApiSubEntity d where d.mc=?1 and d.id <>?2")
        public List<DevtApiSubEntity> getOneDataByMcAndId(String mc, String id);


        @Query("select d from DevtApiSubEntity d where d.dm=?1 and d.id <>?2")
        public List<DevtApiSubEntity> getOneDataByDmAndId(String dm, String id);

         @Query("select d from DevtApiSubEntity d where d.mc like ?1 and d.mainid=?2")
         public List<DevtApiSubEntity> findByCondition(String input, String mainid);

        @Query("select d from DevtApiSubEntity d where d.mc like ?1")
        public List<DevtApiSubEntity> findByMc(String mc);

}
